package com.hudson.plugin.result.collector.server.router;

import org.apache.camel.builder.RouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

/**
 * User: yuxinlei
 * Date: 4/13/11
 * Time: 11:37 AM
 */
public class HudsonDataRouter  extends RouteBuilder implements InitializingBean {
    private static final Logger logger = LoggerFactory.getLogger(HudsonDataRouter.class)      ;

    private String incomeQueue;
    private String outcomeQueue;
    private String secondInQueue;
    private String secondOutQueue;
    public void afterPropertiesSet() throws Exception {
        logger.debug("the HudsonDataRouter is start , with the params " +
                "sourceUri : " + getIncomeQueue() + "" +
                " queueName : " + getOutcomeQueue());
    }

    @Override
    public void configure() throws Exception {
        logger.debug("start the router process");
        from(getIncomeQueue()).inOut(getOutcomeQueue())   ;
        from(getSecondInQueue()).split(body()).to(getSecondOutQueue()) ;
    }

    public String getIncomeQueue() {
        return incomeQueue;
    }

    public void setIncomeQueue(String incomeQueue) {
        this.incomeQueue = incomeQueue;
    }

    public String getOutcomeQueue() {
        return outcomeQueue;
    }

    public void setOutcomeQueue(String outcomeQueue) {
        this.outcomeQueue = outcomeQueue;
    }

    public String getSecondInQueue() {
        return secondInQueue;
    }

    public void setSecondInQueue(String secondInQueue) {
        this.secondInQueue = secondInQueue;
    }

    public String getSecondOutQueue() {
        return secondOutQueue;
    }

    public void setSecondOutQueue(String secondOutQueue) {
        this.secondOutQueue = secondOutQueue;
    }
}
